/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.qsdm.es.persistence;

import java.io.Serializable;
import java.util.List;
import javax.persistence.*;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author alberto
 */
@Entity
@Table(name = "idioma", catalog = "qsdm", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Idioma.findAll", query = "SELECT i FROM Idioma i"),
    @NamedQuery(name = "Idioma.findById", query = "SELECT i FROM Idioma i WHERE i.id = :id"),
    @NamedQuery(name = "Idioma.findByNombre", query = "SELECT i FROM Idioma i WHERE i.nombre = :nombre"),
    @NamedQuery(name = "Idioma.findByCodISO6391", query = "SELECT i FROM Idioma i WHERE i.codISO6391 = :codISO6391")})
public class Idioma implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "id", nullable = false)
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer id;
    @Column(name = "nombre", length = 45)
    private String nombre;
    @Column(name = "codISO6391", length = 3)
    private String codISO6391;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idioma1", fetch = FetchType.LAZY)
    private List<Usuarioidioma> usuarioidiomaList;

    public Idioma() {
    }

    public Idioma(Integer id) {
        this.id = id;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getNombre() {
        return nombre;
    }

    public void setNombre(String nombre) {
        this.nombre = nombre;
    }

    public String getCodISO6391() {
        return codISO6391;
    }

    public void setCodISO6391(String codISO6391) {
        this.codISO6391 = codISO6391;
    }

    @XmlTransient
    public List<Usuarioidioma> getUsuarioidiomaList() {
        return usuarioidiomaList;
    }

    public void setUsuarioidiomaList(List<Usuarioidioma> usuarioidiomaList) {
        this.usuarioidiomaList = usuarioidiomaList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Idioma)) {
            return false;
        }
        Idioma other = (Idioma) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.qsdm.es.persistence.Idioma[ id=" + id + " ]";
    }
    
}
